package hiho.week._88;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int p = in.nextInt();
		int q = in.nextInt();
		in.close();
		
		List<Integer> pDivisor = getDivisors(p);
		List<Integer> qDivisor = getDivisors(q);
		for (Integer i : pDivisor)
			for (Integer j : qDivisor)
				System.out.println(String.format("%d %d", i, j));
	}
	
	private static List<Integer> getDivisors(int n) {
		List<Integer> result = new ArrayList<Integer>();
		for (int i = 1; i <= n; i++)
			if (n % i == 0)
				result.add(i);
		return result;
	}

}
